package 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author hbb
	 */
	public class AbstractDemo extends Sprite 
	{
		
		public function AbstractDemo():void 
		{
			if (stage) __init();
			else addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private function onAddedToStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			__init();
		}
		
		private function __init():void
		{
			initStage();
			init();
		}
		
		protected function initStage():void 
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.stageFocusRect = false;
		}
		
		protected function init():void { }
		
		
		protected function startLoop():void 
		{
			addEventListener(Event.ENTER_FRAME, loop);
		}
		
		protected function stopLoop():void
		{
			removeEventListener(Event.ENTER_FRAME, loop);
		}
		
		protected function loop(e:Event):void 
		{
		}
		
		
	}
	
}